/*
 * Copyright (c) 2017 tujia.com. All Rights Reserved.
 */

package com.zhongke.cotrun.common.handler;


import com.google.common.base.Joiner;
import com.zhongke.cotrun.model.pojo.StringSet;
import org.apache.commons.collections.CollectionUtils;

public class StringSetHandler extends BasicTypeHandler<StringSet> {
    @Override
    protected StringSet fromString(String set) {
        StringSet strset = new StringSet();
        String[] sets = set.split(",");
        for (String s : sets) {
            strset.add(s);
        }
        return strset;
    }

    @Override
    protected String toString(StringSet set) {
        if (CollectionUtils.isEmpty(set)) {
            return "";
        }
        return Joiner.on(",").join(set);
    }
}
